package edison.jcr.nodetype;

import javax.jcr.Value;
import javax.jcr.nodetype.PropertyDefinition;
import edison.jcr.SessionContext;
import edison.persistence.PropertyDefinitionBean;

public class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition {

	protected int requiredType;
	protected String[] valueConstraints;
	protected Value[] defaultValues;
	protected boolean isMultiple;
	protected String[] availableQueryOperators;
	protected boolean isFullTextSearchable;
	protected boolean isQueryOrderable;

	PropertyDefinitionImpl(SessionContext context) {
		super(context);
	}

	PropertyDefinitionImpl(SessionContext context, PropertyDefinitionBean bean) {
		super(context);
		this.name = bean.getName();
		this.isAutoCreated = bean.isAutoCreated();
		this.isMandatory = bean.isMandatory();
		this.onParentVersionAction = bean.getOnParentVersionAction();
		this.isProtected = bean.isProtected();
		this.declaringNodeTypeName = bean.getDeclaringNodeType();
	}

	public int getRequiredType() {
		return requiredType;
	}

	public String[] getValueConstraints() {
		return valueConstraints.clone();
	}

	public Value[] getDefaultValues() {
		return defaultValues.clone();
	}

	public boolean isMultiple() {
		return isMultiple;
	}

	public String[] getAvailableQueryOperators() {
		return availableQueryOperators.clone();
	}

	public boolean isFullTextSearchable() {
		return isFullTextSearchable;
	}

	public boolean isQueryOrderable() {
		return isQueryOrderable;
	}

}